package com.anabur.dao;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;

public class DAOFactory {
	
	protected SessionFactory sessionFac;
	private static DAOFactory instance;
	
	private DAOFactory(){
		Configuration config = new AnnotationConfiguration().configure();
		sessionFac = config.buildSessionFactory();
	}
	
	public static DAOFactory getInstance(){
		if(instance==null){
			instance=new DAOFactory();
		}
		return instance;
	}
	
	public void resetSessionFactory(){
		sessionFac=new AnnotationConfiguration().configure().buildSessionFactory();
	}
	
	public UserDAO getUserDAO() {
		return new UserDAO(sessionFac);
	}
	
	public CotizacionDAO getCotizacionDAO() {
		return new CotizacionDAO(sessionFac);
	}
	
	public BalanceDAO getBalanceDAO() {
		return new BalanceDAO(sessionFac);
	}
	
	public EmpresaDAO getEmpresaDAO() {
		return new EmpresaDAO(sessionFac);
	}
	
	public RubroDAO getRubroDAO() {
		return new RubroDAO(sessionFac);
	}
}
